package com.ccys.cms.service.inventory.impl;

import com.ccys.cms.service.inventory.InventoryFeedService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.web.inventory.InventoryFeedDto;
import com.ccys.db.entity.TblInventoryFeed;
import com.ccys.db.mapper.TblInventoryFeedMapper;
import com.ccys.db.page.PageDto;
import com.ccys.db.rely.service.impl.BaseServiceImpl;
import com.ccys.db.vo.web.inventory.InventoryFeedVo;
import com.ccys.db.vo.web.inventory.ProductInfoFeedVo;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class InventoryFeedServiceImpl extends BaseServiceImpl<TblInventoryFeed> implements InventoryFeedService {


    @Resource
    private TblInventoryFeedMapper mapper;

    @Override
    public ResponseResult getPage(InventoryFeedDto dto) {

        //根据当前用户groupid
        //超级管理员的区分 (超级管理员没有groupId 不会进查询条件)
        if (StringUtils.isEmpty(dto.getGroupId())) {
            String groupId = dto.getGroupId();
            dto.setGroupId(groupId);
        }
        PageDto.startPage();
        List<InventoryFeedVo> list = mapper.getList(dto);
        PageInfo<InventoryFeedVo> info = new PageInfo<>(list);
        return ResponseResult.success(info);
    }

    @Override
    public ProductInfoFeedVo getProductInfoByBatchNo(String batchNo) {
        return mapper.getProductInfoByBatchNo(batchNo);
    }
}
